#include <linux/module.h>



// #define REG_BASE 0x900000001fe105100
#define REG_BASE 0x1fe10500
struct reg_gpio
{
    uint32_t GPIO0_OEN_L;   uint32_t GPIO0_OEN_H;
    uint32_t GPIO1_OEN_L;   uint32_t GPIO1_OEN_H;

    uint32_t GPIO0_O_L;     uint32_t GPIO0_O_H;
    uint32_t GPIO1_O_L;     uint32_t GPIO1_O_H;

    uint32_t GPIO0_I_L;     uint32_t GPIO0_I_H;
    uint32_t GPIO1_I_L;     uint32_t GPIO1_I_H;

    uint32_t GPIO0_INTEN_L; uint32_t GPIO0_INTEN_H;
    uint32_t GPIO1_INTEN_L; uint32_t GPIO1_INTEN_H;

};

static int __init ls2k_gpio_init(void)
{
    uint64_t *paddr;
    uint64_t val;
    struct reg_gpio *reg;

    paddr = ioremap(REG_BASE, 4*1024);
    val = readl(paddr);
    
    printk("paddr 0x%0.16lx\r\n", paddr);
    printk("val 0x%0.16lx\r\n", val);

    reg = (struct reg_gpio*)paddr;
    printk(
        "GPIO0_OEN_L 0x%0.16lx = 0x%0.16lx\r\n"
        "GPIO0_OEN_H 0x%0.16lx = 0x%0.16lx\r\n"
        "GPIO0_O_L   0x%0.16lx = 0x%0.16lx\r\n"
        "GPIO0_O_H   0x%0.16lx = 0x%0.16lx\r\n",
            &reg->GPIO0_OEN_L, reg->GPIO0_OEN_L,
            &reg->GPIO0_OEN_H, reg->GPIO0_OEN_H,
            &reg->GPIO0_O_L,    reg->GPIO0_O_L,
            &reg->GPIO0_O_H,   reg->GPIO0_O_H);    
    
    // 交替切换GPIO63的输出值
    writel(0x80000000 ^ reg->GPIO0_O_H, &reg->GPIO0_O_H);
    // reg->GPIO0_O_H = reg->GPIO0_O_H ^ 0x80000000;

    return 0;
}

static void __exit ls2k_gpio_exit(void)
{

}



module_init(ls2k_gpio_init);
module_exit(ls2k_gpio_exit);
